package com.sunlands.deskmate.message.entity;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable;

@Document
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Messages implements Serializable {

    private static final long serialVersionUID = 6449924345759139152L;
    /**
     * 用户客户端向服务端发送消息时，进行幂等检查
     */
    private String requestId;
    @Id
    @ApiModelProperty(value = "消息id")
    private String id;
    @ApiModelProperty(value = "消息类型(参考wiki:长链接数据格式及 type 定义)", required = true)
    private String type;
    @ApiModelProperty(value = "发送到哪里，一般为 个人id、群id、或房间id，根据 type 字段区分（比如 type 为 204，那么 toId 就是 群id）", required = true)
    private String toId;
    @ApiModelProperty(value = "真实发送到人的userId", required = true)
    private Long realToId;
    @ApiModelProperty(value = "发送者id", required = true)
    private String fromUserId;
    @ApiModelProperty(value = "消息创建时间")
    private String createTime;
    @ApiModelProperty(value = "消息内容", required = true)
    private String message;
    @ApiModelProperty(value = "业务id，用来承载业务相关id，如群id、房间id，一般分享、邀请的时候会用到")
    private String contentId;
    @ApiModelProperty(value = "contentId 的 type")
    private String contentType;
    @ApiModelProperty(value = "扩展属性")
    private JSONObject extras;
    private String retype;
    @ApiModelProperty(value = "链接类型，取值 ：web ，app")
    private String connectType;
    /**
     * 用于消息去重排序
     */
    @ApiModelProperty(value = "ackId")
    private Long ackId;

    @Override
    public Messages clone() {
        Messages msgEntity = null;
        try {
            msgEntity = (Messages) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return msgEntity;
    }

}
